package com.example.jdai.jdai.ui;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.FragmentManager;
import android.content.DialogInterface;
import android.os.Bundle;
import android.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.jdai.jdai.R;

/**
 * Created by hellopyj on 2017/1/12.
 */

public class MyDialog extends DialogFragment {

    OkClick okClick;
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState)
    {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        LayoutInflater inflater = getActivity().getLayoutInflater();
        View view = inflater.inflate(R.layout.mydialog, null);
        builder.setView(view)
                // Add action buttons
                .setPositiveButton("确定",
                        new DialogInterface.OnClickListener()
                        {
                            @Override
                            public void onClick(DialogInterface dialog, int id)
                            {
                                if(okClick!=null){
                                    okClick.clickOk();
                                }
                            }
                        }).setNegativeButton("取消", null);
        return builder.create();
    }
    public interface OkClick
    {
        void clickOk();
    }
    void setOkClick(OkClick okClick){
        this.okClick=okClick;
    }
}
